﻿Imports System.Xml.Serialization

<XmlRoot("Compound")> Public Class tagCompound
    Inherits tagBase

    <XmlElement("Byte")> Public Bytes As New List(Of tagByte)
    <XmlElement("Short")> Public Shorts As New List(Of tagShort)
    <XmlElement("Int")> Public Ints As New List(Of tagInt)
    <XmlElement("Long")> Public Longs As New List(Of tagLong)
    <XmlElement("Float")> Public Floats As New List(Of tagFloat)
    <XmlElement("Double")> Public Doubles As New List(Of tagDouble)
    <XmlElement("ByteArray")> Public ByteArrays As New List(Of tagByteArray)
    <XmlElement("String")> Public Strings As New List(Of tagString)
    <XmlElement("List")> Public Lists As New List(Of tagList)
    <XmlElement("Compound")> Public Compounds As New List(Of tagCompound)
    <XmlElement("IntArray")> Public IntArrays As New List(Of tagIntArray)

    Public Sub New()

    End Sub

    Friend Sub New(ByVal str As System.IO.Stream, Optional ByVal SkipName As Boolean = False)
        MyBase.New(str, SkipName)

        Dim NextElementType As Byte
        Do
            NextElementType = ReadBytesFromStream(str, 1)(0)
            Select Case NextElementType
                Case 1
                    Me.Bytes.Add(New tagByte(str))
                Case 2
                    Me.Shorts.Add(New tagShort(str))
                Case 3
                    Me.Ints.Add(New tagInt(str))
                Case 4
                    Me.Longs.Add(New tagLong(str))
                Case 5
                    Me.Floats.Add(New tagFloat(str))
                Case 6
                    Me.Doubles.Add(New tagDouble(str))
                Case 7
                    Me.ByteArrays.Add(New tagByteArray(str))
                Case 8
                    Me.Strings.Add(New tagString(str))
                Case 9
                    Me.Lists.Add(New tagList(str))
                Case 10
                    Me.Compounds.Add(New tagCompound(str))
                Case 11
                    Me.IntArrays.Add(New tagIntArray(str))
                Case Else
                    NextElementType = 0
            End Select
        Loop Until NextElementType = 0
    End Sub

End Class
